package gui.data.D2;

import gui.MyFrame;

import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

@SuppressWarnings("serial")
public class QuadrangleOutputGui extends JPanel {
	JTextField adInput, dcInput, cbInput, baInput, dabAngleInput,
			abcAngleInput, bcdAngleInput, cdaAngleInput, d1Input, d2Input,
			areaInput, circumfInput, heightInput;
	JLabel adLbl, dcLbl, cbLbl, baLbl, dabAnglel, abcAnglel, bcdAnglel,
			cdaAnglel, d1Lbl, d2Lbl, areaLbl, circumfLbl, heightLbl;

	public QuadrangleOutputGui(int guide, double adLength, double dcLength,
			double cbLength, double baLength, double dabAngle, double abcAngle,
			double bcdAngle, double cdaAngle, double diagonal1,
			double diagonal2, double circumference, double area, double height) {

		this.setLayout(new GridLayout(0, 4));
		this.setPreferredSize(new Dimension(500, 500));

		String[] shapes = { "Square", "Oblong", "Rhombus", "Rhomboid",
				"Trapezium", "Kite" };
		JComboBox shapeSelector = new JComboBox(shapes);
		shapeSelector.setSelectedIndex(4);

		adLbl = new JLabel("Length of |AD|");
		dcLbl = new JLabel("Length of |DC|");
		cbLbl = new JLabel("Length of |CB|");
		baLbl = new JLabel("Length of |BA|");

		dabAnglel = new JLabel("Angle " + "\u2220DAB");
		abcAnglel = new JLabel("Angle " + "\u2220ABC");
		bcdAnglel = new JLabel("Angle " + "\u2220BCD");
		cdaAnglel = new JLabel("Angle " + "\u2220CDA");

		adInput = new JTextField(adLength == 0 ? "N/A" : "" + adLength);
		dcInput = new JTextField(dcLength == 0 ? "N/A" : "" + dcLength);
		cbInput = new JTextField(cbLength == 0 ? "N/A" : "" + cbLength);
		baInput = new JTextField(baLength == 0 ? "N/A" : "" + baLength);

		dabAngleInput = new JTextField(dabAngle == 0 ? "N/A" : "" + dabAngle);
		abcAngleInput = new JTextField(abcAngle == 0 ? "N/A" : "" + abcAngle);
		bcdAngleInput = new JTextField(bcdAngle == 0 ? "N/A" : "" + bcdAngle);
		cdaAngleInput = new JTextField(cdaAngle == 0 ? "N/A" : "" + cdaAngle);

		d1Lbl = new JLabel("Diagonal 1 (|AC|)");
		d2Lbl = new JLabel("Diagonal 2 (|DB|)");

		d1Input = new JTextField(diagonal1 == 0 ? "N/A" : "" + diagonal1);
		d2Input = new JTextField(diagonal2 == 0 ? "N/A" : "" + diagonal2);

		circumfLbl = new JLabel("Circumference");
		areaLbl = new JLabel("Area");

		circumfInput = new JTextField(circumference == 0 ? "N/A" : ""
				+ circumference);
		areaInput = new JTextField(area == 0 ? "N/A" : "" + area);

		heightLbl = new JLabel("Height (AB to DC)");
		heightInput = new JTextField(height == 0 ? "N/A" : "" + height);
		
		shapeSelector.setSelectedIndex(guide-1);
		shapeSelector.setEnabled(false);
		
		adInput.setEditable(false);
		dcInput.setEditable(false);
		cbInput.setEditable(false);
		baInput.setEditable(false);
		dabAngleInput.setEditable(false);
		abcAngleInput.setEditable(false);
		bcdAngleInput.setEditable(false);
		cdaAngleInput.setEditable(false);
		d1Input.setEditable(false);
		d2Input.setEditable(false);
		areaInput.setEditable(false);
		circumfInput.setEditable(false);
		heightInput.setEditable(false);

		this.add(new JLabel(""));
		this.add(new JLabel(""));
		this.add(new JLabel(""));
		this.add(new JLabel(""));
		this.add(new JLabel("Type of quadrangle"));
		this.add(shapeSelector);
		this.add(new JLabel(""));
		this.add(new JLabel(""));
		this.add(new JLabel(""));
		this.add(new JLabel(""));
		this.add(new JLabel(""));
		this.add(new JLabel(""));
		// side lengths
		this.add(adLbl);
		this.add(adInput);
		this.add(dcLbl);
		this.add(dcInput);
		this.add(cbLbl);
		this.add(cbInput);
		this.add(baLbl);
		this.add(baInput);
		// angles
		this.add(dabAnglel);
		this.add(dabAngleInput);
		this.add(abcAnglel);
		this.add(abcAngleInput);
		this.add(bcdAnglel);
		this.add(bcdAngleInput);
		this.add(cdaAnglel);
		this.add(cdaAngleInput);
		// diagonals
		this.add(d1Lbl);
		this.add(d1Input);
		this.add(d2Lbl);
		this.add(d2Input);
		// circumference and area
		this.add(circumfLbl);
		this.add(circumfInput);
		this.add(areaLbl);
		this.add(areaInput);
		// height
		this.add(heightLbl);
		this.add(heightInput);
		// calculate
		this.add(new JLabel(""));
	}
}
